package chapter15.exercise.ch15;

import com.common.utils.Generator;

public class GeneratorsTest {
    public static int size = 10;

    public static void test(Class<?> surroundingClass) {
        for (Class<?> type : surroundingClass.getClasses()) {
            System.out.print(type.getSimpleName() + ": ");
            try {
                Generator<?> gen = (Generator<?>) type.newInstance();
                for (int i = 0; i < size; i++)
                    System.out.print(gen.next() + " ");
                System.out.println();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }

    public static void main(String[] args) {
//		test(CountingGererator.class);
        //测试一下System.arraycopy
        Integer[] a = {1, 2, 3, 4, 5};
        Integer[] b = new Integer[10];
        System.arraycopy(a, 0, b, 0, 5);
        for (Integer integer : b) {
            System.out.print(integer + " ");
        }
    }
}
